<?php


	if( !isset($_COOKIE["username"]) ){
		header("Location:login.php");
	}else{
		setcookie("username", $_COOKIE["username"],time() + 900);
	}
	
	
	$ini_array = parse_ini_file("config/config.ini", true);
	
	$conn = @mysqli_connect($ini_array["host"], $ini_array["username"], $ini_array["password"], $ini_array["db_name"]) or die("cann't connect the mysql db");
	mysqli_set_charset($conn, "utf8");
	ini_set('default_charset', "UTF-8");
	$patientNo = mysqli_real_escape_string($conn,$_POST["patientNo"]);
	
	$sql = "select count(patient_no) count from patient where patient_no=".$patientNo;
	$result = mysqli_query($conn, $sql);
	
	$data = "{\"data\":{";
	if( $row = mysqli_fetch_array($result)){
		$count = $row["count"];
		if( $count == 0 ){
			$data .= "\"exist\":\"false\"}}";
		}else{
			$data .= "\"exist\":\"true\"}}";
		}
	}
	echo $data;
	
?>